package com.sl.au.service.impl;

import java.util.*;

import com.sl.au.entity.*;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.repository.TaskRepository;
import com.sl.au.service.IndexService;
import com.sl.au.service.SectionService;
import com.sl.utils.DataConverter;

import org.springframework.util.StringUtils;

@Service("IndexService")
@Transactional
public class IndexServiceImpl extends BaseServiceImpl implements IndexService {
	@Autowired
	TaskRepository taskRepository;
	@Autowired
	SectionService sectionService;
	@Override
	public TaskRepository getRepository() {

		return this.taskRepository;
	}


	@Override
	public List<Task> getMyTask(int start, int length, String userId, String roleId) {
		Page<Task> pages = null;
		Pageable pageable = new PageRequest(start / length, length, Sort.Direction.DESC, "createTime");
		pages = taskRepository.getMyTask(userId, roleId, pageable);
		return pages.getContent();
	}


	@Override
	public Map<String, Object> newAddCount(Map<String, String> condition) {
		Map<String, Object> count=new HashMap<String, Object>();	
		long contractCount=0;
		long customerCount=0;
		long chanceCount=0;		
		contractCount=this.getNewContract(condition);
		chanceCount=this.getNewChance(condition);
		customerCount=this.getNewCustomer(condition);
		count.put("contractCount", contractCount);
		count.put("cusCount", customerCount);
		count.put("chanceCount", chanceCount);
		return count;
	}



	@Override
	public void getAafterSale() {
		// TODO Auto-generated method stub
		
	}


	@Override
	public long getNewChance(Map<String, String> condition) {
		// TODO Auto-generated method stub
		return 0;
	}


	@Override
	public long getNewContract(Map<String, String> condition) {
		// TODO Auto-generated method stub
		return 0;
	}


	@Override
	public long getNewCustomer(Map<String, String> condition) {
		// TODO Auto-generated method stub
		return 0;
	}
}
